﻿using System;
using System.Web;
using System.Web.Caching;
using TweetSayingsLibrary.App.DataDoc;
using TweetSayingsLibrary.Twitter;

namespace TweetSayingsLibrary.App.Entity
{
    public class Trends
    {
        public static IDataDoc Current()
        {
            IDataDoc trends = HttpContext.Current.Cache.Get("TrendsCurrent") as IDataDoc;
            if (trends == null)
            {
                trends = new DataDocJson(() => GeneralPublic.Get("http://search.twitter.com/trends.json"));
                HttpContext.Current.Cache.Add("TrendsCurrent", trends, null, DateTime.Now.AddMinutes(2), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
            }
            
			return trends;
        }
    }
}